package x.ovo.wechat.bot.common.command;

import x.ovo.wechat.bot.common.Context;
import x.ovo.wechat.bot.common.entity.message.TextMessage;
import x.ovo.wechat.bot.common.plugin.Plugin;

/**
 * 命令执行器
 *
 * @author ovo, created by 2024/05/02
 */
public abstract class CommandExecutor {

    /** 持有插件对象，获取其中的插件信息 */
    protected final Plugin plugin;
    protected final Context context;

    public abstract void execute(Command command, TextMessage message);

    protected CommandExecutor(Plugin plugin) {
        this.plugin = plugin;
        this.context = plugin.getContext();
    }

    protected boolean inAuthors(String name) {
        return plugin.getDescription().getAuthors().contains(name);
    }
}
